package edu.gatech.oad.mule;

import static org.junit.Assert.*;

import org.junit.*;

import edu.gatech.oad.mule.MULEStable;
import edu.gatech.oad.mule.Store;
import edu.gatech.oad.mule.ConfigurationPanel;
import edu.gatech.oad.mule.TownMap;

public class TownMapTest {
	private MULEStable stable;
	private Store store;
	private ConfigurationPanel config;
	private TownMap tm;
	private int muleAmountBefore;
	private int initialSmithore;
	
	@Before
	public void setUp(){
		config = new ConfigurationPanel();
		store = new Store(0,0,100,100,config);
		stable = new MULEStable(200, 200, 100, 100, config);
		stable.setMULECount(0);
		store.setSmithore(0);
		tm = new TownMap(store, stable);
	}
	
	@Test
	public void testSetUp() {
		assertEquals(0, stable.getMULECount());
		assertEquals(0, store.getSmithore());
	}
	
	@Test
	public void testNoSmithore() {
		initialSmithore = 0;
		store.setSmithore(initialSmithore);
		tm.production();
		assertEquals(0, stable.getMULECount());
	}
	
	@Test
	public void test2Smithore() {
		initialSmithore = 2;
		store.setSmithore(initialSmithore);
		muleAmountBefore = stable.getMULECount();
		tm.production();
		assertEquals(muleAmountBefore + initialSmithore / 2, stable.getMULECount());
	}
	
	@Test
	public void testOddSmithore() {
		initialSmithore = 3;
		store.setSmithore(initialSmithore);
		tm.production();
		assertEquals(muleAmountBefore + initialSmithore / 2, stable.getMULECount());
	}
	
	@Test
	public void testManySmithore() {
		initialSmithore = 10;
		store.setSmithore(initialSmithore);
		muleAmountBefore = stable.getMULECount();
		tm.production();
		assertEquals(muleAmountBefore + initialSmithore / 2, stable.getMULECount());
	}
}
